package com.kan.bargain.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.kan.bargain.entity.RecordingEntity;
import com.kan.bargain.service.RecordingService;
import com.miao.commonn.utils.PageUtils;
import com.miao.commonn.utils.R;



/**
 * 
 *
 * @author xk
 * @email 2337156522@QQ.com
 * @date 2022-03-10 10:51:39
 */
@RestController
@RequestMapping("bargain/recording")
public class RecordingController {
    @Autowired
    private RecordingService recordingService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = recordingService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{rid}")
    public R info(@PathVariable("rid") Integer rid){
		RecordingEntity recording = recordingService.getById(rid);

        return R.ok().put("recording", recording);
    }


    @RequestMapping("/findlist")
    public List<RecordingEntity> findlist(@RequestParam Integer boid){

        QueryWrapper<RecordingEntity> boid1 = new QueryWrapper<RecordingEntity>().eq("boid", boid);

        List<RecordingEntity> list = recordingService.list(boid1);

        return list;
    }



    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody RecordingEntity recording){
		recordingService.save(recording);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody RecordingEntity recording){
		recordingService.updateById(recording);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] rids){
		recordingService.removeByIds(Arrays.asList(rids));

        return R.ok();
    }

}
